var app = getApp();
var util = require("../../utils/util.js");
var siteinfo = require('../../siteinfo.js');
Page({
  data: {

  },
  onLoad: function (options) {
    this.setData({
      id: options.id,
      stuSignUpId: options.stuSignUpId
    })
    this.getList(options.id)
  
  },

  onShow: function () {
  },

  //获取证书考试信息
  getList: function (id) {
    var _this = this;
    app._get(siteinfo.selCertificateDetail, {
      id: id
    }, function (result) {
      _this.setData(result.data);
    });
  },
//微信支付
pay:function(){
  var _this = this;
  wx.login({
    success: function (res) {
        app._post_form(siteinfo.wxPay, {
          body: '报名费用',
          trade_type: 'JSAPI',
          stuSignUpId: _this.data.stuSignUpId
        }, function (result) {
          if (result.code == 10018 || result.code == '10018') {
            wx.showModal({
              title: '友情提示',
              content: '微信登录未授权,请使用微信账号快速登录',
              confirmText: '去授权',
              success: function (res) {
                if (res.confirm) {
                  app.doLogin()
                }
              }
            })
            return false
          }
          wx.requestPayment({
            timeStamp: result.data.wx.data.timeStamp,
            nonceStr: result.data.wx.data.nonce_str,
            package: result.data.wx.data.prepay_id,
            signType: 'MD5',
            paySign: result.data.wx.data.sign,
            success: function (res) {
           //  console.log("支付成功",res)
              wx.navigateTo({
                url: '/pages/signSuccess/signSuccess',
              })
            }
          })
        });
      }
      })
 
},

 
})